package com.yiqi.news.mvp.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yiqi.huize.loadImage
import com.yiqi.news.R
import com.yiqi.news.app.utils.DateUtils
import com.yiqi.news.app.utils.TimeUtils
import com.yiqi.news.entity.Comment
import kotlinx.android.synthetic.main.item_comment.view.*
import kotlinx.android.synthetic.main.item_label.view.*

class CommentAdapter : BaseQuickAdapter<Comment, BaseViewHolder>(R.layout.item_comment) {


    override fun convert(helper: BaseViewHolder, item: Comment) {
        val itemView = helper.itemView
        itemView.tv_comment_content.text = item.commentInfo
        itemView.tv_comment_nick.text = item.fromUserNick
        itemView.iv_comment_avatar.loadImage(item.fromUserHeadImg)
//        itemView.tv_comment_date.text = DateUtils.getShortTime(item.createTime * 1000L)
        itemView.tv_comment_date.text = TimeUtils.stampToDate4(item.createTime)
        itemView.tv_comment_like_count.text = item.commentZanCount.toString()
        itemView.iv_comment_like.setImageResource(if (!item?.haveZan.isNullOrEmpty() && item?.haveZan == "1") R.mipmap.ic_toolbar_news_like else R.mipmap.ic_toolbar_news_dislike)
        helper.addOnClickListener(R.id.iv_comment_comment).addOnClickListener(R.id.btn_comment_like_count).addOnClickListener(R.id.tv_reply)

        if (item.ratingReplyVoList != null && item.ratingReplyVoList.size > 0) {
            helper.setText(R.id.tv_reply, "查看${item.ratingReplyVoList.size}条回复")
        }
        helper.setGone(R.id.tv_reply, item.ratingReplyVoList != null && item.ratingReplyVoList.size > 0)


    }


}
